package com.kele.controller;

import com.kele.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Collection;

/**
 * @Version 2019
 * @Author:kele
 * @Date:2021/8/8
 * @Content:
 * @Description：
 */
@RestController
public class ConsumerController {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/findAll")
    public Collection<User> findAll(){
        return restTemplate.getForEntity("http://localhost:8010/findAll",Collection.class).getBody();
    }
    @GetMapping("/findAll2")
    public Collection<User> findAll2(){
        return restTemplate.getForObject("http://localhost:8010/findAll",Collection.class);
    }

    @GetMapping("/findById/{id}")
    public User findById(){
       return restTemplate.getForEntity("http://localhost:8010/findById/{id}",User.class).getBody();
    }

    @GetMapping("/findById/{id}")
    public User findById2(){
        return restTemplate.getForObject("http://localhost:8010/findById/{id}",User.class);
    }
}
